package com.kty.cesuan.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.kty.cesuan.mapper.KnowledgeMapper;
import com.kty.cesuan.pojo.Knowledge;
import com.kty.cesuan.service.KnowledgeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class KnowledgeServiceImpl extends ServiceImpl<KnowledgeMapper, Knowledge> implements KnowledgeService {

    @Autowired
    private KnowledgeService knowledgeService;

//**********************************************************************************************************************

    /**
     * 查询知识
     *
     * @param page     页数
     * @param pageSize 每页条数
     */
    public Page<Knowledge> pageInfo(int page, int pageSize) {

        // 1、分页构造
        Page<Knowledge> pageInfo = new Page<>(page, pageSize);

        // 2、条件构造（封装构造条件）
        LambdaQueryWrapper<Knowledge> qw = new LambdaQueryWrapper<>();
        // 2.1、排序条件：根据操作时间降序
        qw.orderByAsc(Knowledge::getId);

        // 3.3、查询
        return knowledgeService.page(pageInfo, qw);

    }

}
